package com.itWaiLong.Controller.Learning;

import com.itWaiLong.Dao.learning_resource;
import com.itWaiLong.Result.Result;
import com.itWaiLong.Service.LearningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/learning/select")
public class SelectLearningController {

    @Autowired
    private LearningService learningService;

    /**
     * 通过资料id查询资料
     * @param resourceId
     * @return
     */
    @GetMapping("/ById")
    public Result<learning_resource> ById(Integer resourceId){
        learning_resource learningResource = learningService.selectById(resourceId);
        return Result.success(learningResource);
    }

    /**
     * 查询所有学习资料
     * @return
     */
    @GetMapping("/selectAll")
    public Result<List<learning_resource>> selectAll(){
        List<learning_resource> list = learningService.selectAll();
        return Result.success(list);
    }
}
